<template>
	<view>
		<view class="table">
			<table border="0" width="95%" cellspacing="0" cellpadding="0">
				<tr>
					<td>物品名称</td>
					<td>购买数量</td>
					<td>支付金额</td>
					<td>抵扣金额</td>
				</tr>
				<tr v-for="(item,index) in list" :key="index">
					<td>{{item.name}}</td>
					<td>{{item.num}}</td>
					<td>{{item.pay_money}}</td>
					<td>{{item.offset_money}}</td>
				</tr>
			</table>
		</view>
		
		<view class="formTe" v-if="formShow">
			<view>物品名称:{{info.stock_name}}</view>
			<view>购买数量:{{info.num}}</view>
			<view>购买用户:{{info.username}}</view>
			<view>实收金额:{{info.price}}</view>
			<view>支付方式:{{info.payType == 1 ? '账户抵扣' : '现金'}}</view>
			<view>购买日期:{{info.addtime}}</view>
			<view class="viewButton" @click="close">关闭</view>
		</view>
	</view>
</template>
<script>
import request from '@/util/request.js'
export default {
	data() {
		return {
			page:1,
			pageShow:false,
			list:[],
			member_id:0,
			formShow:false
		}
	},
	onLoad:function(e){
		this.member_id = e.id
		uni.showLoading({
			title:'加载中.'
		})
		this.getList()
	},
	methods: {
		getList:function(){
			var data = {
				page:this.page,
				member_id:this.member_id
			}
			var that = this
			request({
				url: 'manage/order/list',
				method: 'get',
				data:data,
				success: (res) => {
					uni.hideLoading();
					if(res.data.data.last_page <= that.page){
						that.pageShow = false
					}
					if(that.page == 1){
						that.list = res.data.data.data
					}else{
						var list = that.list
						that.list = list.concat(res.data.data.data)
					}
				},
			})
		},
		onReachBottom: function(){
			if(this.pageShow){
				 //当前不是最后一页可加载
				 this.page = this.page + 1
				 uni.showLoading()
				 this.getList();
			}
		},
		show:function(item){
			this.info = item
			this.formShow = true
		},
		close:function(){
			this.formShow = false
		},
		search:function(e){
			this.keyword = e.detail.value
			this.page = 1
			this.pageShow = true
			uni.showLoading()
			this.getList();
		},
	},
}
</script>
<style>
@import url("../css/public.css");
</style>